package com.oscarmovie.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.oscarmovie.model.Music;

public class MusicDaoImpl extends HibernateDaoSupport implements MusicDao {

	
	public void save(Music music) {
		getSession().saveOrUpdate(music);
	}

	public Music load(int id) {
		Music music = (Music)getSession().load(Music.class, id);
		return music;
	}
	
	
	public List<Music> loadAll() {
		Query query = getSession().createQuery("from Music music");
		query.setCacheable(true);
		List<Music> list = (List<Music>)query.list();
		return list;
	}
	
}
